package com.yootk.editor;

import com.yootk.vo.Address;

import java.beans.PropertyEditorSupport;

/**
 * 属性编辑器
 */
public class AddressPropertyEdit extends PropertyEditorSupport {

    @Override
    public void setAsText(String text) throws IllegalArgumentException {
        // 当资源设置之后，会触发此方法的执行
        String[] result = text.split("-");
        Address address = new Address();
        address.setCountry(result[0]);
        address.setProvice(result[1]);
        address.setCity(result[2]);
        super.setValue(address);    // 保存Bean对象
    }
}
